package android.cs2340UDT;

/*
 * Class manages the getters and setters of Item
 */
public class Item {
	
	private String description;
	private String location;
	private String dueDate;
	private String comment;
	private boolean completed;
	private String category;
	private int month;
	private int day;
	private int hour;
	
	/**
	 * Constructor for an item.
	 * 
	 * @param description The description of an item.
	 * @param location The location of an item.
	 * @param month The month an item is due.
	 * @param day The day an item is due.
	 * @param hour The hour an item is due.
	 * @param comment A comment about the item.
	 */
	public Item(String description, String location, String dueDate, String comment) {
		this.description = description;
		this.location = location;
		this.comment = comment;
		//this.month = month;
		//this.day = day;
		//this.hour = hour;
		this.dueDate = dueDate;
		
		completed = false;
		category = "";
		
		alert = null;
	}
	
	/**
	 * Method sets the description of an item
	 * 
	 * @param the description of the item
	 */
	public void setDescription(String description)	{
		this.description = description;
	}
	/**
	 * Method returns the description
	 * 
	 * @return the description of the item
	 */
	public String getDescription()	{
		return description;
	}
	
	/**
	 * Method returns the location
	 * 
	 * @return the location of the item
	 */
	public String getLocation()	{
		return location;
	}
	/**
	 * Method sets the location
	 * 
	 * @param the location of the item
	 */
	public void setLocation(String location)	{
		this.location = location;
	}
	
	/**
	 * Method returns the due date
	 * 
	 * @return the due date of the item
	 */
	public String getDueDate()	{
		return dueDate;
	}
	
	public String getFormattedDueDate() {
		String temp = "";
		temp.concat(dueDate.substring(0, 2));
		temp.concat(" / ");
		temp.concat(dueDate.substring(2, 4));
		temp.concat(" / ");
		temp.concat(dueDate.substring(4));
		return temp;
	}
	/**
	 * Method sets the Due Date
	 * 
	 * @param the due date of the item
	 */
	public void setDueDate(String dueDate)	{
		this.dueDate = dueDate;
	}
	/**
	 * Getter for month
	 * 
	 * @return The month something is due.
	 */
	public int getMonth()	{
		return month;
	}
	/**
	 * Getter for day
	 * 
	 * @return The day something is due.
	 */
	public int getDay()	{
		return day;
	}
	/**
	 * Getter for hour
	 * 
	 * @return The hour something is due.
	 */
	public int getHour() {
		return hour;
	}
	/**
	 * Setter for month
	 * 
	 * @param month The month something is due.
	 */
	public void setMonth(int month)	{
		this.month = month;
	}
	/**
	 * Setter for day
	 * 
	 * @param month The day something is due.
	 */
	public void setDay(int day)	{
		this.day = day;
	}
	/**
	 * Setter for hour
	 * 
	 * @param month The hour something is due.
	 */
	public void setHour(int hour)	{
		this.hour = hour;
	}
	/**
	 * Method returns the comment of the item
	 * 
	 * @return the comment of the item
	 */
	public String getComment() {
		return comment;
	}
	/**
	 * Method sets any comments
	 * 
	 * @param the comment of the item
	 */
	public void setComment(String comment)	{
		this.comment = comment;
	}
	
	
	/**
	 * Method sets the complete
	 * 
	 * @param the completeness of the item
	 */
	public void setComplete(boolean complete)	{
		completed = complete;
	}
	
	/**
	 * Method returns the completeness of the item
	 * 
	 * @return the completeness of the item
	 */
	public boolean getComplete()	{
		return completed;
	}
	
	
	/**
	 * Method sets the Category of the item
	 * 
	 * @param the category of the item
	 */
	public void setCategory(String cat)	{
		category = cat;
	}
	
	/**
	 * Method returns the category of the item
	 * 
	 * @return the category of the item
	 */
	public String getCategory()	{
		return category;
	}
	
	
	/**
	 * Method sets the alert
	 * 
	 * @param the alert of the item
	 */
	public void setAlert(Alert alert)	{
		this.alert = alert;
	}
	
	public int getDate() {
		return Integer.parseInt(dueDate);
	}
	
	public int checkInfo(String name, String location, String month, String day, String year, String comment) {
		int result = 0;
		
		if(month.length() != 2 || day.length() != 2 || year.length() != 4) {
			result = 1;
		}
		// need correct regex here to ensure the full date string contains only numbers
		else if((month.concat(day)).concat(year) == null) {
			result = 1;
		}
		else if(Integer.parseInt(month) > 12 || Integer.parseInt(month) < 1 || Integer.parseInt(day) > 31 || Integer.parseInt(day) < 1) {
			result = 1;
		}
		
		return result;
	}
	

}
